#pragma once

#include "../NetLib/NetCommon.h"
#include "../NetLib/NetSession.h"

class ChatSession : public NetSession
{
    typedef NetSession super;
public:
    ChatSession(boost::asio::io_service& service);
    virtual ~ChatSession();

    virtual void Start();
    virtual void Close();

    virtual bool ReadPacket();

    virtual bool OnCommandMsg() = 0;
    virtual bool OnGeneralMsg() = 0;

public:
    bool GetParameter(char* buf, size_t bufLen);

    void ClearMsg();

public:
    const char* GetCommand() const {
        return command_.c_str(); 
    }

protected:
    bool PumpMsg();

    bool IsReturned() const {
        return (('\n' == msgBuf_[msgLen_-1]) || isMsgFull_);
    }

    bool IsCommandMsg() const {
        return (msgBuf_[0] == '/');
    }

protected:
    bool isMsgFull_;
    size_t msgLen_;
    char msgBuf_[MAX_C2S_MSGSIZE];
    std::string command_;

};
